package 测试1;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by hest0 on 2017/7/12.
 */
public class 蛇形矩阵 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String line = sc.nextLine();
            int n = Integer.parseInt(line);
            int[][] a = func(n);

            int step = 0;
            for (int i = 0; i <= a.length - 1; i++) {
                for (int j = 0; j <= a.length - 1 - step; j++) {
                    if (j < a.length - 1 - step) {
                        System.out.print(a[i][j]);
                        System.out.print(" ");
                    } else if (j == a.length - 1 - step) {
                        System.out.println(a[i][j]);
                    }
                }
                step++;
            }

        }
        sc.close();
    }

    private static int[][] func(int n) {
        int[][] a = new int[n][n];
        int len = n * (n + 1) / 2;

        int[] x = new int[len];
        int[] y = new int[len];

        int idx1 = 0;
        int idx2 = 0;
        for (int i = 0; i < len; i++) {
            for (int j = i; j >= 0; j--)
                if (idx1 < len)
                    x[idx1++] = j;
            for (int j = 0; j <= i; j++)
                if (idx2 < len)
                    y[idx2++] = j;
        }

        int num = 1;
        int idxxy = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (idxxy < len)
                    a[x[idxxy]][y[idxxy++]] = num++;
            }
        }

        System.out.println(Arrays.toString(x));
        System.out.println(Arrays.toString(y));

        return a;
    }
}
